package com.tlias.service.impl;

import com.tlias.mapper.DeptMapper;
import com.tlias.pojo.Dept;
import com.tlias.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptMapper deptMapper;
//查找
    @Override
    public List<Dept> selectDept() {
        List<Dept> deptList = deptMapper.findAllDept();
        return deptList;
    }
//删除
    @Override()
    public void deleteById(Integer id) {
        //调用持久层删除功能
        deptMapper.deleteById(id);
    }


//添加
    @Override
    public void addDept(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        dept.setCreateTime(LocalDateTime.now());
        deptMapper.addDept(dept);

    }
//更改
    @Override
    public void updateDept(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.updateDept(dept);

    }

//id查询
    @Override
    public Dept findById(Integer id) {
        Dept dept = deptMapper.findByIdDept(id);

        return dept;
    }


}

